﻿<%if not in_sdcms then response.write("template load fail"):response.end() end if%>
<!DOCTYPE html>
<!--[if IE 8]>			<html class="ie ie8"> <![endif]-->
<!--[if IE 9]>			<html class="ie ie9"> <![endif]-->
<!--[if gt IE 9]><!-->
<html>
<!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Keywords" content="{sdcms[seokey]}" />
<meta name="Description" content="{sdcms[seodesc]}" />
<title>上传产品-{sdcms[webname]}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{webroot}theme/default/style/css/font-awesome.css" type="text/css" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/owl.carousel.css" media="screen" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/owl.theme.css" media="screen" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/bootstrap.3.2.0.css" type="text/css" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/bootstrap-select.css" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/theme.css" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/theme-elements.css" type="text/css" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/theme-animate.css" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/theme-shop.css" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/settings.css" media="screen" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/component.css" media="screen" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/bim.css" type="text/css" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/custom.css" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/theme-responsive.css" />
<link rel="stylesheet" href="{webroot}theme/default/style/css/datepicker3.css" />
<link rel="stylesheet" href="{webroot}theme/default/css/other.css" />
<link href="{webroot}theme/admin/css/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE]>
        <link rel="stylesheet" href="{webroot}theme/default/style/css/ie.css">
    <![endif]-->
<!--[if lte IE 8]>
        <script src="{webroot}theme/default/style/js/respond.js"></script>
    <![endif]-->
<script src="{webroot}lib/js/jquery.js"></script>
<script>var webroot="{webroot}";</script>
<script src="{webroot}lib/tips/jquery.tips.js"></script>
<script src="{webroot}lib/js/base.js"></script>

<script src="{webroot}lib/js/jquery-migrate-1.1.0.min.js"></script>
<script src="{webroot}lib/js/jquery-ui.min.js"></script>
<script src="{webroot}lib/js/jquery.uploader.js"></script>
<script src="{webroot}lib/validator/jquery.validator.js"></script>
<script src="{webroot}lib/validator/zh_CN.js"></script>
<script src="{webroot}theme/default/js/sdcms.js"></script>
<script src="{webroot}lib/js/jquery.livequery.js"></script>
<script src="{webroot}lib/dialog/artdialog.js"></script>
<script src="{webroot}theme/default/style/js/fancyBox.js" type="text/javascript"></script>



<script>$(function(){$("#user_menu_08").addClass("hover");})</script>
<script>
$(function(){
		$(".selectFile").live("click", function() {
        var a = $(this).attr("config"),
            b = a.split(":"),
            c = b[0],
            d = b[1],
            e = b[2],
            f = b[3];
        top.dialog({
            title: "文件上传",
            content: "<iframe src='/admin/upload.asp?filetype=" + d + "&cid=" + e + "&classid=" + f + "' width='560' height='400' frameborder='0' id='niceupload'></iframe>",
            padding: "10px",
            ok: function() {
                var a = $("#att-status", window.top.document.getElementById("niceupload").contentWindow.document).html();
                if (null != a) {
                    var b, d,temp;
                    b = a.substring(0, 1), d = a.substring(1), $("input[id=" + c + "]").attr("value", d)
				 
                }
            },
            cancel: !0
        }).showModal()
    })


	//beigin
	var $addInput=$("#addInput");
	var $tableid=$("#voteitem");
	var $addInput=$("#addInput");
	$addInput.click(function(){
		var sonnum=$("#voteitem li").size();
		var textValueTrHtml='<li><input type="text" name="t29" id="t29_'+sonnum+'" size="10" maxlength="50" class="ip" value="附件'+(sonnum+1)+'" onfocus="if(this.value==&quot;附件'+(sonnum+1)+'&quot;)this.value=&quot;&quot;" onblur="if(this.value==&quot;&quot;)this.value=&quot;附件'+(sonnum+1)+'&quot;" data-rule="附件名称:required;" /><input type="text" name="t30" id="t30_'+sonnum+'" size="30" maxlength="255" class="ip" data-rule="下载地址:required;" /><input type="button" value="本地上传" config="t30_'+sonnum+':2:0:1" class="bnt_save selectFile"><a href="javascript:;" class="leftarr iconfont">&#xe60a;</a><a href="javascript:;" class="rightarr iconfont">&#xe608;</a><a href="javascript:;" class="delarr iconfont">&#xe602;</a><span for="t30_'+sonnum+'" class="msg-box"></span></li>';
	   sonnum=$("#voteitem li").size();
	   if(sonnum==10)
	   {
		   $.fn.tips({content:'最多只能添加10个'});
		   return false;
	   }
	   else
	   {
		   $tableid.append(textValueTrHtml);
		 }
	})
	
	$(".leftarr").live("click", function() {
		var $ValueTr = $(this).parent();
		var $PrevTr = $ValueTr.prev("li");
		var PrevTrIndex = $("#voteitem li").index($PrevTr);
		$PrevTr.insertAfter($ValueTr);
	});
	
	$(".rightarr").live("click", function() {
		var $ValueTr = $(this).parent();
		var $NextTr = $ValueTr.next("li");
		if ($NextTr.length > 0) {
			$NextTr.insertBefore($ValueTr);
		}
	});
	
	$(".delarr").live("click", function() {
		if (confirm("\u60a8\u786e\u5b9a\u8981\u5220\u9664\u5417\uff1f") == true) {
		var sonnum=$("#voteitem li").size()
		 $(this).parent().remove();
		}
	});
	
	var previewHTML='';
	var dnum=1;
	
	

	//begin
	//增加
	$("#addImage").click(function()
	{
		var html="";
			html+='<dl class="move">'
			html+='  <dt><b>图片地址：</b><textarea id="picurl"></textarea><div>一行一个图片地址</div></dt>'
			html+='</dl>'
			top.dialog({
			title:'远程图片',
			content:html,
			ok:function(){
				var t0=window.top.$("#picurl")[0].value;
				if(t0=="")
				{
					alert("\u56fe\u7247\u5730\u5740\u4e0d\u80fd\u4e3a\u7a7a");
					$("#picurl")[0].focus();
					return false
				}
				else
				{
					var picarr;
					picarr=t0.split("\n");
					for(i=0;i<picarr.length;i++){
						var ImageHtml='<li>'
                            ImageHtml+='    <div class="img">'
                            ImageHtml+='        <img src="'+picarr[i]+'" width="100" height="80" border="0">'
                            ImageHtml+='    </div>'
                            ImageHtml+='    <div class="pic_other">'
                            ImageHtml+='        <div class="row-fluid">'
                            ImageHtml+='            <div class="span2"><a href="javascript:;" class="leftarr iconfont">&#xe60a;</a><a href="javascript:;" class="rightarr iconfont">&#xe608;</a><a href="javascript:;" class="delarr iconfont">&#xe602;</a></div>'
                            ImageHtml+='       </div>'
                            ImageHtml+='   </div>'
							ImageHtml+='   <input type="hidden" name="t40" value="'+picarr[i]+'" />'
                            ImageHtml+='</li>'
							$("#ImageArea").prepend(ImageHtml);
					}
				}
								
			},
			cancel:true 
		}).showModal();
	}
	)
	//左移
	$("#ImageArea .leftarr").live("click",function(){
		var $Imageli=$(this).parent().parent().parent().parent();
		var $ImagePrevli=$Imageli.prev("li");
		if($ImagePrevli.length>0){$ImagePrevli.insertAfter($Imageli);}
	});
	
	//右移
	$("#ImageArea .rightarr").live("click",function(){
		var $Imageli=$(this).parent().parent().parent().parent();
		var $ImageNextli=$Imageli.next("li");
		if($ImageNextli.length>0){$ImageNextli.insertBefore($Imageli);}
	});
	
	//删除
	$("#ImageArea .delarr").live("click",function(){
		var thispic=$(this).parent().parent().parent().parent();
			top.dialog({
				content:'\u60a8\u786e\u5b9a\u8981\u5220\u9664\u5417',
				ok:function(){thispic.remove();},
				cancel:true 
			}).showModal();
	});
	//清空
	$("#clearImage").live("click",function() {
		var thispic=$("#ImageArea li");
			top.dialog({
				content:'\u786e\u5b9a\u8981\u6e05\u7a7a\uff1f',
				ok:function(){thispic.remove();},
				cancel:true 
			}).showModal();
	});
	
	var previewHTML='';
    $('#selectFile').uploader({
        action:'/admin/sd_upload.asp?act=json&classid=1&admin_id=0&userid={userid}&loginbase={loginbase}&loginkey={loginkey}',
        name: "file",
        formData:{},
		mode: 'flash',
        multiple:true,
        auto:true,
        fileSizeLimit: '{sdcms[upmaxsize]}KB',
        fileTypeDesc: '选择图片',     
        fileTypeExts: 'jpg,gif,png',
		onProgress: function(e){
            $.fn.tips({type:'loading',content:'文件上传中，请稍后'});
        },
		/*onSelected:function(filelist){
			filelist.length=5;
        },*/
		onError:function(e){
             $.fn.tips({content:e.name});
        },
        onSuccess:function(e){
			data=jQuery.parseJSON(e.data);
            if(data.status=="y")
			{
				var ImageHtml='<li>'
					ImageHtml+='    <div class="img">'
					ImageHtml+='        <img src="'+data.info+'" width="100" height="80" border="0">'
					ImageHtml+='    </div>'
					ImageHtml+='    <div class="pic_other">'
					ImageHtml+='        <div class="row-fluid">'
					ImageHtml+='            <div class="span2"><a href="javascript:;" class="leftarr iconfont">&#xe60a;</a><a href="javascript:;" class="rightarr iconfont">&#xe608;</a><a href="javascript:;" class="delarr iconfont">&#xe602;</a></div>'
					ImageHtml+='       </div>'
					ImageHtml+='   </div>'
					ImageHtml+='   <input type="hidden" name="t40" value="'+data.info+'" />'
					ImageHtml+='</li>'
				previewHTML+=ImageHtml;
			}else{$.fn.tips({content:data.info});}
        },
        onAllComplete:function(){
            if(previewHTML){
                $('#ImageArea').prepend(previewHTML);
				$.fn.tips({type:'ok',content:'上传完成'});
                previewHTML='';
            }
           
        }
    }); 
	//over		

})
</script>
</head>
<body>


<div class="body">
    {sdcms:include("../../sdcms_head.asp")}
   <div id="useragreement-modal" class="modal fade" tabindex="-1">
    <div class="modal-dialog modal-lg">
      <div class="modal-content"></div>
    </div>
  </div>
  <div id="privacy-policy-modal" class="modal fade" tabindex="-1">
    <div class="modal-dialog modal-lg">
      <div class="modal-content"></div>
    </div>
  </div>
  <div role="main" class="main">
    <div class="space10"></div>
    <div id="content" class="content full">
      <div role="main" class="main shop">
        <div class="container">
         <div class="space20"></div>
        <div class="main_left">
        {sdcms:include("../../user/sdcms_menu.asp")}
        </div> 
        <div class="main_right">
        <div class="title">上传产品</div>
         <div class="p12">
                
                 {if sdcms.user_publish_num<0 and id=0}
                                您所在的用户组禁止投稿
                            {elseif sdcms.user_publish_num=0 and id=0}
                                您今日的投稿数量已用完
                            {else}
                            <form class="formname" method="post">
                             <div class="form-group">
                  <label class="col-lg-2 col-md-3 col-sm-3  control-label" for="inputEmail3">产品名称</label>
                  <div class="col-lg-8 col-sm-8">
                    <input  name="t0" id="t0"    maxlength="255" type="text" class="bitian form-control"  placeholder="请填产品名称" data-toggle="popover" data-content="请填写产品名称" value="{title}" data-placement="top" data-trigger="hover"><font color="#ff0000"> * </font>
                  </div>
                </div>   
                             <div class="form-group">
											<label for="inputPassword3" class="col-lg-2 col-md-3 col-sm-3 control-label">产品描述</label>
											<div class="col-lg-8 col-sm-8">
												<textarea class="form-control" rows="6"  name="t1" placeholder="请产品描述" data-toggle="popover" title="请概括填写产品描述"  lang="请概括填写产品描述" data-placement="top" data-trigger="hover">{content}</textarea><font color="#ff0000"> * </font>
											</div>
										</div>  
                                        
             <div class="form-group">
            <label for="inputPassword3" class="col-lg-2 col-md-3 col-sm-3 control-label">产品图片：</label>
          <div class="col-lg-10 col-sm-10">
                <input type="button" value="本地上传" class="bnt_save" style="margin-left:0px !important;" id="selectFile"><input type="button" value="网络图片" class="bnt_normal" id="addImage"><input type="button" value="清空产品图片" class="bnt_normal" id="clearImage"><font color="#ff0000">* 图片大小建议385px*385px</font>
                <ul class="piclist" id="ImageArea">
                </ul>
            </div>
        </div>                           
                                         
  
  <div class="form-group">
           <label for="inputPassword3" class="col-lg-2 col-md-3 col-sm-3 control-label">上传附件：</label>
          	<div class="col-lg-10 col-sm-10">
            <input type="button" value="添加一条" class="bnt_normal" id="addInput">
               <ul class="voteitem" id="voteitem">
               </ul>
            </div>
        </div>                                        
                                    
                                        
          {if isarray(field_data)}
        {for i=0 to ubound(field_data,2)}
        <div class="form-group">
          <label for="inputPassword3" class="col-lg-2 col-md-3 col-sm-3 control-label">{field_data(1,i)}：</label>
           	<div class="col-lg-8 col-sm-8">{get_self_field(field_data(0,i),field_data(1,i),field_data(2,i),field_data(3,i),field_data(5,i),field_data(7,i),field_data(8,i),field_data(9,i),"",field_data(11,i),0,field_data(6,i),0)}
            </div>
        </div>
        {/for}
        {/if}
        
                             <div style="height:50px; line-height:50px; margin:0 auto; width:80px">	<button type="submit" data-rel="6" class="btn btn-primary  next">提交</button></div>
                            </form>
                            {/if}
                            
                
                </div>
        </div> 
        <div class="clear"></div>
        </div>
      </div>
    </div>
  </div>
  <script>
	$(".formname").validator(
		{
			stopOnError:true,
			theme:'yellow_right',
			ignore:':hidden',
			beforeSubmit:function(){$("input[type='submit']").attr("disabled",true);},
			valid:function(form)
			{
				
				if($("input[name=t30]").length<=0)
			{
				$.fn.tips({content:"请至少添加一个附件"});
				$("input[type='submit']").attr("disabled",false);
				return false;
			}
			
				if($("input[name=t40]").length<=0)
			{
				$.fn.tips({content:"请至少添加或上传一张产品图片"});
				$("input[type='submit']").attr("disabled",false);
				return false;
			}
			
				$.fn.tips({type:'loading',content:'数据提交中'});
				$.ajax(
				{
					url:"?act=db&classid={classid}&id={id}",
					type:"post",
					data:$(form).serialize(),
					success:function(data){
						data=jQuery.parseJSON(data);
						var type="warn";
						if(data.status=="y"){type="ok";}
						$.fn.tips({type:type,content:data.info});
						if(data.status=="y"){setTimeout('location.href="publish.asp"',1000);}
						else
						{$("input[type='submit']").attr("disabled",false);}
						
					}
				});
			},
			invalid:function(){$("input[type='submit']").attr("disabled",false);}
		}
	);
	</script>
    
    {sdcms:include("../../sdcms_foot.asp")}
  </div>
<script src="{webroot}theme/default/style/js/jqueryappear.js"></script> 



  <!-- Libs -->
    <script src="{webroot}theme/default/style/js/plugins.js"></script>
    <script src="{webroot}theme/default/style/js/jquery.easing.js"></script>
    
    <script src="{webroot}theme/default/style/js/jquery.cookie.js"></script>

    <script src="{webroot}theme/default/style/js/bootstrap.min.3.2.0.js"></script>
    <script type="text/javascript" src="{webroot}theme/default/style/js/tooltip.js"></script>
    <script src="{webroot}theme/default/style/js/jquery.themepunch.tools.min.js"></script>

    <script src="{webroot}theme/default/style/js/bootstrap-select.min.js"></script>


<script type="text/javascript">

        var setDropDownBackground = function(selectElement) {
            var element = $(selectElement);
            var className = element.data('active-class');
            var nextButton = element.next('div').children('button').first();

            if (nextButton.length > 0) {
                if (element.val()) {
                    nextButton.addClass(className);
                } else {
                    nextButton.removeClass(className);
                }
            }

        };

        $(document).ready(function() {

            $('select.selectpicker').selectpicker();
            $('select.selectpicker').change(function() {
                setDropDownBackground(this);
            });

            //init dropdowns
            $('select.selectpicker').each(function(key, value) {
                setDropDownBackground(value);
            });

        });
			
    </script>
</body>
</html>